﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Data.Common;
namespace DuJianliang.ApplicationPlatform.Proj5715.Process
{
    public partial class ProcessEdit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["DispatchMissileProcessID"] = Request.QueryString["DispatchMissileProcessID"].Trim();
                ProcessDal dal = new ProcessDal();
                DispatchMissileProcessOB obj = dal.GetDispatchMissileProcessById(ViewState["DispatchMissileProcessID"].ToString());
                if (obj != null)
                {
                    txt_SectionCode.Text = obj.SectionCode;
                } 
            }
        }

        protected void btn_OK_Click(object sender, EventArgs e)
        {
            string strSectionCode = txt_SectionCode.Text.Trim();

            string sql = "UPDATE t5715_DispatchMissileProcess "+
                         "SET  SectionCode = '" + strSectionCode + "', " +
                          "IsBeginRepair=1,BeginRepairDate=getdate()" +
                         " WHERE DispatchMissileProcessID ='" + ViewState["DispatchMissileProcessID"].ToString()+"'";
            try
            {
                Database database = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = database.GetSqlStringCommand(sql);
                database.ExecuteNonQuery(dbCommand);

                Response.Write("<script>alert('领修完成！');</script>");
                Response.Write("<script>window.opener = null;window.open('', '_self', '');window.close();</script>");
            }
            catch (Exception exp)
            {
                throw exp;
            }

        }
    }
}